#pragma once

#include <iostream>
#include <boost/asio.hpp>

#include "Server.h"

using boost::asio::ip::tcp;
class Server;

class Session : public std::enable_shared_from_this<Session>
{
public:
	Session(boost::asio::io_context& ioc, Server* server);

	tcp::socket& Socket();

	std::string& GetUuid() {
		return m_uuid;
	}

	void Start();
private:
	void handle_read(const boost::system::error_code& error, size_t bytes_transferred, std::shared_ptr<Session> _self_session);
	void handle_write(const boost::system::error_code& error, std::shared_ptr<Session> _self_session);

	Server* m_server;
	static const size_t MAX_LENGTH = 1024;
	tcp::socket m_socket;
	char m_data[MAX_LENGTH]{};
	std::string m_uuid;
};

